package com.qiaofang.housewarehouse.stub.feign.client.impl;

import com.qiaofang.common.exception.BusinessException;
import com.qiaofang.housewarehouse.stub.constants.ResponseCode;
import com.qiaofang.housewarehouse.stub.facade.CityQueryFacade;
import com.qiaofang.housewarehouse.stub.facade.HouseCollectionCharacterFacade;
import com.qiaofang.housewarehouse.stub.feign.client.CityQueryClient;
import com.qiaofang.housewarehouse.stub.feign.client.HouseCollectionCharacterClient;
import com.qiaofang.housewarehouse.stub.request.CityDistricRequest;
import com.qiaofang.housewarehouse.stub.request.CityRegionRequest;
import com.qiaofang.housewarehouse.stub.response.CityDistricResponse;
import com.qiaofang.housewarehouse.stub.response.CityRegionResponse;
import com.qiaofang.housewarehouse.stub.response.SaleAndRentalByCityResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("houseCollectionCharacterClient")
public class HouseCollectionCharacterClientImpl implements HouseCollectionCharacterClient {

    @Autowired
    private HouseCollectionCharacterFacade houseCollectionCharacterFacade;

    @Override
    public SaleAndRentalByCityResponse querySaleAndRentalByCity(CityDistricRequest cityDistricRequest) {
        SaleAndRentalByCityResponse response = houseCollectionCharacterFacade.querySaleAndRentalByCity(cityDistricRequest);
        if (ResponseCode.RC_SUCCESS.getResponseCode().equals(response.getResponseCode())) {
            return response;
        } else {
            throw new BusinessException(response.getResponseCode(), response.getResponseMessage());
        }
    }
}
